<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: yangweijie <yangweijiester@gmail.com> <code-tech.diandian.com>
// +----------------------------------------------------------------------


namespace Addons\SystemInfo;
use Common\Controller\Addon;
use Admin\Controller\OrdersController;
use Admin\Controller\ProductController;
/**
 * 系统环境信息插件
 * @author thinkphp
 */

    class SystemInfoAddon extends Addon{

        public $info = array(
            'name'=>'IndexInfo',
            'title'=>'系统环境信息',
            'description'=>'用于显示一些服务器的信息',
            'status'=>1,
            'author'=>'thinkphp',
            'version'=>'0.1'
        );

        public function install(){
            return true;
        }

        public function uninstall(){
            return true;
        }

        //实现的AdminIndex钩子方法
        public function admin_index($param){
            $config = $this->getConfig();
            $Order=new OrdersController();
            $result=$Order->getlastinfo();
            $order=$result['order']['info'];
            $user=$result['user']['info'];
            $this->assign('last_info', $order);

            $this->assign('user',$user);
            $this->assign('order_count',$result['count']['info']);
            $product=new ProductController();
            $count=$product->getIndex();
            $this->assign('onshelf',$count['onshelf']['info']);
            $this->assign('not_onshelf',$count['not_onshelf']['info']);

            if($config['display']){
                $this->display('widget');
            }
        }
    }